<?php
class lappettycashcontroller extends CI_Controller{
	function __construct(){
		parent::__construct();
		$this->load->helper('form');
		$this->load->library('form_validation');
		$this->load->model('lappettycash_model');
	}

	function index(){
		if (isset($_POST['btnview'])) {
			if ((isset($_POST['tglawal']) && isset($_POST['tglakhir']))
			&& (!empty($_POST['tglawal']) && !empty($_POST['tglakhir'])))
			{
				$this->lappettycash_model->setTanggalAwal($_POST['tglawal']);
				$this->lappettycash_model->setTanggalAkhir($_POST['tglakhir']);

				$dataprofile = array(
					'page_title' => 'Laporan > Petty Cash',
					'name' => $this->session->userdata('fullname'),
					'dt_petty' => $this->lappettycash_model->getListtanggal(),
					'tglAwal' => $_POST['tglawal'],
					'tglAkhir' => $_POST['tglakhir']
				);
			}
			else if(isset($_POST['kdview'])){
				if($_POST['kdview'] == "0")
				{
					$dataprofile = array(
						'page_title' => 'Laporan > Petty Cash',
						'name' => $this->session->userdata('fullname'),
						'dt_petty' => $this->lappettycash_model->getList()		
					);
				}
				elseif($_POST['kdview'] == "1")
				{
					$this->lappettycash_model->setKdtransaksi($_POST['namaview']);
					$dataprofile = array(
						'page_title' => 'Laporan > Petty Cash',
						'name' => $this->session->userdata('fullname'),
						'dt_petty' => $this->lappettycash_model->getkdtranslike()
					);
				}
				elseif($_POST['kdview'] == "2")
				{
					$this->lappettycash_model->setKodepettycash($_POST['namaview']);
					$dataprofile = array(
						'page_title' => 'Laporan > Petty Cash',
						'name' => $this->session->userdata('fullname'),
						'dt_petty' => $this->lappettycash_model->getkdpettylike()
					);
				}
				elseif($_POST['kdview'] == "3")
				{
					$this->lappettycash_model->setnamapettycash($_POST['namaview']);
					$dataprofile = array(
						'page_title' => 'Laporan > Petty Cash',
						'name' => $this->session->userdata('fullname'),
						'dt_petty' => $this->lappettycash_model->getnamapettylike()
					);
				}
				elseif($_POST['kdview'] == "4")
				{
					$this->lappettycash_model->setKeterangan($_POST['namaview']);
					$dataprofile = array(
						'page_title' => 'Laporan > Petty Cash',
						'name' => $this->session->userdata('fullname'),
						'dt_petty' => $this->lappettycash_model->getketpettylike()
					);
				}
			}
		}
		else
		{
			$dataprofile = array(
				'page_title' => 'Laporan > Petty Cash',
				'name' => $this->session->userdata('fullname'),
				'dt_petty' => $this->lappettycash_model->getList()		
			);
		}
		$content = array(
			'content' => 'laporan/lappettycash'
			);
			$this->template->load('templates/default',$content,$dataprofile);
	}

	function toExcel()
	{
		if (isset($_POST['btntoxl']))
		{
			if ((isset($_POST['tglAwal']) && isset($_POST['tglAkhir']))
			&& (!empty($_POST['tglAwal']) && !empty($_POST['tglAkhir'])))
			{
				$this->lappettycash_model->setTanggalAwal($_REQUEST['tglAwal']);
				$this->lappettycash_model->setTanggalAkhir($_REQUEST['tglAkhir']);
				$dataprofile = array(
					'page_title' => 'Laporan > Petty Cash',
					'name' => $this->session->userdata('fullname'),
					'dt_petty' => $this->lappettycash_model->getListtanggal()
				);
			}
			else if (isset($_POST['kdview'])){
				if($_REQUEST['kdview'] == "0")
				{
					$dataprofile = array(
					'page_title' => 'Laporan > Petty Cash',
					'name' => $this->session->userdata('fullname'),
					'dt_petty' => $this->lappettycash_model->getList()		
					);
				}
				else if($_REQUEST['kdview'] == "1")
				{
					$this->lappettycash_model->setKdtransaksi($_REQUEST['namaview']);
					$dataprofile = array(
					'page_title' => 'Laporan > Petty Cash',
					'name' => $this->session->userdata('fullname'),
					'dt_petty' => $this->lappettycash_model->getkdtranslike()
					);
				}
				else if($_REQUEST['kdview'] == "2")
				{
					$this->lappettycash_model->setKodepettycash($_REQUEST['namaview']);
					$dataprofile = array(
					'page_title' => 'Laporan > Petty Cash',
					'name' => $this->session->userdata('fullname'),
					'dt_petty' => $this->lappettycash_model->getkdpettylike()
					);
				}
				else if($_REQUEST['kdview'] == "3")
				{
					$this->lappettycash_model->setnamapettycash($_REQUEST['namaview']);
					$dataprofile = array(
					'page_title' => 'Laporan > Petty Cash',
					'name' => $this->session->userdata('fullname'),
					'dt_petty' => $this->lappettycash_model->getnamapettylike()
					);
				}
				else if($_REQUEST['kdview'] == "4")
				{
					$this->lappettycash_model->setKeterangan($_REQUEST['namaview']);
					$dataprofile = array(
					'page_title' => 'Laporan > Petty Cash',
					'name' => $this->session->userdata('fullname'),
					'dt_petty' => $this->lappettycash_model->getketpettylike()
					);
				}
			}
			/*
			 elseif($_REQUEST['kdpettycs'] != "")
			 {
				$this->lappettycash_model->setKodepettycash($_REQUEST['kdpettycs']);
				$dataprofile = array(
				'page_title' => 'Laporan > Petty Cash',
				'name' => $this->session->userdata('fullname'),
				'dt_petty' => $this->lappettycash_model->getkdpettylike()
				);
				}
				else{

				$dataprofile = array(
				'page_title' => 'Laporan > Petty Cash',
				'name' => $this->session->userdata('fullname'),
				'dt_petty' => $this->lappettycash_model->getList()
				);
				}*/
				
		}		
		$content = array
		(
			'content' => 'laporan/excelpettycash'
			);

			$this->load->view('laporan/excelpettycash',$dataprofile);
	}

}